import request from "@utils/request";
import { getChatToken, getAdminToken } from "@/utils/storage";

export const getRtcConnectData = (room: string, identity: string) =>
  request.post<{ serverUrl: string; token: string }>(
    "/user/rtc/get_token",
    JSON.stringify({
      room,
      identity,
    }),
    {
      headers: {
        token: getChatToken(),
      },
    }
  );

export const getAdminRtcConnectData = (room: string, identity: string) =>
  request.post(
    process.env.NODE_ENV === "production"?process.env.ADMIN_URL + "/api/rtc/admin/getUserRtcToken": "/api/rtc/admin/getUserRtcToken",
    JSON.stringify({
      room,
      identity,
    }),
    {
      headers: {
        token: getAdminToken()
      },
    }
  );

export const getAdminUserInfo = () =>
  request.get(
    process.env.ADMIN_URL + "/api/b/v1/user/info",
    {
      headers: {
        token: getAdminToken(),
      },
    }
  );

export const getImLogin = () =>
  request.get<{ serverUrl: string; token: string }>(
    process.env.ADMIN_URL + "/api/b/v1/user/im_login",
    {
      headers: {
        token: getAdminToken(),
      },
    }
  );

export const getinviteeUserInfo = (id: string) =>
  request.get<{ serverUrl: string; token: string }>(
    process.env.ADMIN_URL + "/api/b/v1/work/user/info?userId=" + id,
    {
      headers: {
        token: getAdminToken(),
      },
    }
  );
